/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package descent;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Luke
 */
public class Dice {
    ArrayList<Die> red = new ArrayList<Die>();
    ArrayList<Die> blue = new ArrayList<Die>();
    ArrayList<Die> white = new ArrayList<Die>();
    ArrayList<Die> green = new ArrayList<Die>();
    ArrayList<Die> yellow = new ArrayList<Die>();
    ArrayList<Die> black = new ArrayList<Die>();
    ArrayList<Die> clear = new ArrayList<Die>();
    
    public Dice(String[] colors){
        for(String die : colors){
            if (die == "red"){
                red.add(new Die("red"));
            } else if (die == "blue"){
                blue.add(new Die("blue"));
            } else if (die == "white"){
                white.add(new Die("white"));
            } else if (die == "green"){
                green.add(new Die("green"));
            } else if (die == "yellow"){
                yellow.add(new Die("yellow"));
            } else if (die == "black"){
                black.add(new Die("black"));
            } else if (die == "clear"){
                clear.add(new Die("clear"));
            }
        }
    }
    
    public int[] diceRoll() { 
        int totalWounds = 0;
        int totalRange = 0;
        int totalSurges = 0;;
        int[] sideUp;
        int[] totals = new int[3];
        boolean miss;
        int[] missRoll = {0,0,0};
        miss = false;
        for (Die die : red){
            sideUp = die.Roll();
            if (sideUp[0] == -1){
                miss = true;
            }
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2];
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        for (Die die : blue){
            sideUp = die.Roll();
            if (sideUp[0] == -1){
                miss = true;
            }
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2];  
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        for (Die die : white){
            sideUp = die.Roll();
            if (sideUp[0] == -1){
                miss = true;
            }
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2];    
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        for (Die die : green){
            sideUp = die.Roll();
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2]; 
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        for (Die die : yellow){
            sideUp = die.Roll();
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2];   
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        for (Die die : black){
            sideUp = die.Roll();
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2];   
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        for (Die die : clear){
            sideUp = die.Roll();
            if (sideUp[0] == -1){
                miss = true;
            }
            totalRange = totalRange + sideUp[0];
            totalWounds = totalWounds + sideUp[1];           
            totalSurges = totalSurges + sideUp[2];   
            System.out.println("Range: " + sideUp[0] + " , " + "Wounds: " + sideUp[1] + " , " + "Surges: " + sideUp[2]);
        }
        
        totals[0] = totalRange;
        totals[1] = totalWounds;
        totals[2] = totalSurges;
        
        if (miss){
            System.out.println("You missed!");
            return missRoll;
        } else {
            System.out.println("Total Range: " + totals[0] + " , " + "Total Wounds: " + totals[1] + " , " + "Total Surges: " + totals[2]);
            return totals;
        }
    }
    
    public static void main(String args[]){
        int[] attack;
        String[] colors = {"red", "blue", "white", "black", "black", "clear"};
        Dice dice = new Dice(colors);
        attack = dice.diceRoll();  
        System.out.println("Attack Range: " + attack[0] + " , " + "Attack Wounds: " + attack[1] + " , " + "Attack Surges: " + attack[2]);
    }
        
}

